package org.knight.gearbox.service;

import org.knight.gearbox.controller.DemoBizDataVO;
import org.knight.gearbox.controller.QueryVO;
import org.knight.gearbox.model.entity.DemoBizData;
import org.knight.gearbox.repository.BizDataRepository;
import org.knight.gearbox.security.UserContextUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BizService {


    @Autowired
    private BizDataRepository bizRepo;

    public List<DemoBizData> queryBizData(QueryVO queryVO) {
      return  bizRepo.queryBizData(queryVO.getAttr1(), UserContextUtil.getBuIds());
    }


    public void  doSomeBusiness(DemoBizDataVO vo) {
        ///something dummy
        DemoBizData po = new DemoBizData();
        BeanUtils.copyProperties(vo, po);
        bizRepo.save(po);
    }
}
